import Router from 'vue-router'
import routes from './routes'
export default () => {
  return new Router({
    routes,
    mode: 'history',
    // base: '/home/',
    linkActiveClass: 'active-class',
    linkExactActiveClass: 'exact-active-class',
    scrollBehavior (to, from, savedPosition) {
      if (savedPosition) {
        return savedPosition
      } else {
        return { x: 0, y: 0 }
      }
    },
    fallback: true
    // Router.beforeEach((to, from, next) => {
    //   if (to.matched.some(record => record.meta.requiresAuth)) {
    //     // this route requires auth, check if logged in
    //     // if not, redirect to login page.
    //     if (!auth.loggedIn()) {
    //       next({
    //         path: '/login',
    //         query: { redirect: to.fullPath }
    //       })
    //     } else {
    //       next()
    //     }
    //   } else {
    //     next() // 确保一定要调用 next()
    //   }
    // })
  })
}
